home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Arsenal Files 4
/
The Arsenal Files 4 (Arsenal Computer).ISO
/
casm
/
au116-as.exe
/
UTIL
/
CD.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1994-05-08
|
1KB
|
64 lines
#include "..\au.hpp"
#include <errno.h>
/*************************************************************************/
/* supplements the lacking turboc chdir() command */
STATUS cd(AU *au, char *string, char *old_dir, BYTE dispError)
{
char temp_dir[FLENGTH];
char string2[FLENGTH];
int temp;
if (old_dir != NULL)
getcwd(old_dir, FLENGTH);
if (string[0]=='\0') /* Don't remove this, 10 lines down will cause you grief */
return SUCCESS;
strcpy(string2,string);
/* strip the trialing \ if it exists */
temp = strlen(string2);
if (temp > 1 && string2[temp-1] == '\\' && string2[temp-2] != ':')
string2[temp-1] = '\0';
temp=0;
getcwd(temp_dir,FLENGTH); /* don't do anything if already there */
if (stricmp(string2, temp_dir)==0)
return SUCCESS;
if (string2[1]==':')
{
temp=2;
setdisk(toupper(string2[0]) - 'A');
}
if (string2[temp] != '\0')
{
if (chdir(string2+temp) == -1)
{
if (dispError)
{
au_printf_error(au, "Invalid Directory '%s'", string2);
exit(1);
}
else
return FAILURE;
}
}
return SUCCESS;
}
/*************************************************************************/
BOOLEAN dir_exists(AU *au, char *dir)
{
char old_dir[FLENGTH];
int retCode;
retCode = cd(au, dir, old_dir, FALSE);
if (retCode < 0)
return FALSE;
cd(au, old_dir);
return TRUE;
}